关于try{}catch{}的问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 14:50:55
try {
i=0;
}catch ( Exception ex ) {
log.error( "++++ error " );
}
如果要求:在出现了异常的时候,在执行了log.error("++++ error ")之后,要再去执行try{}里面的语句,直到不再抛出异常为止,应该怎么写啊?

单写个方法,重新调用本方法,在CATCH里写好抛错后的处理

class test {

public static void main(String[] args) {
int[] array = new int[]{1};
int i = 10;
while (true) {
try {
i--;
System.out.println(array[i]);
return;
} catch (Exception ex) {
System.out.println("++++ error ");
}
}
}
}
看看把